<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org"
>
<head>
    <script th:src="@{/vendor/jquery/jquery.min.js}"></script>
    <script th:src="@{/vendor/bootstrap/js/bootstrap-table.js}"></script>
    <!--BootstrapCoreJavaScript-->
    <script th:src="@{/vendor/bootstrap/js/bootstrap.min.js}"></script>
    <!--MetisMenuPluginJavaScript-->
    <script th:src="@{/vendor/metisMenu/metisMenu.min.js}"></script>
    <!--CustomThemeJavaScript-->
    <script th:src="@{/dist/js/sb-admin-2.js}"></script>
    <script th:src="@{/vendor/datepicker/bootstrap-datepicker.js}"></script>
    <link href="/vendor/bootstrap/css/bootstrap-table.css" rel="stylesheet">
    <link href="/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
    <!--MetisMenuCSS-->
    <link href="/vendor/metisMenu/metisMenu.min.css" rel="stylesheet">
    <!--CustomCSS-->
    <link href="/dist/css/sb-admin-2.css" rel="stylesheet">
    <link href="/vendor/datepicker/datepicker3.css" rel="stylesheet">
    <!--CustomFonts-->
    <link href="/vendor/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
    <meta charset="UTF-8">
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>ApplySerial</title>

    <!--BootstrapCoreCSS-->


</head>

<body>

<div id="page-ApplySerial">
    <ul id="myTab" class="nav nav-tabs">
        <li class="active">
            <a href="#home" data-toggle="tab">
                贷款申请(授信)
            </a>
        </li>
    </ul>
    <div class="tab-pane fade in active" id="home">

        <div class="panel panel-default">
            <div class="panel-heading">
                <h4 class="panel-title">
                    <a data-toggle="collapse" data-parent="#accordion" href="#collapseOne">贷款申请(授信)</a>
                </h4>
            </div>
            <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
                 aria-hidden="true">
                <div class="modal-dialog">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                                &times;
                            </button>
                            <h4 class="modal-title" id="myModalLabel">
                                确认信息
                            </h4>
                        </div>
                        <div class="modal-body">
                            确认要申请贷款吗？
                        </div>
                        <div class="modal-footer">
                            <button type="button" id="cancel" class="btn btn-default" data-dismiss="modal">
                                取消
                            </button>
                            <button type="button" id="confirm" class="btn btn-primary">
                                确认
                            </button>
                        </div>
                    </div><!-- /.modal-content -->
                </div><!-- /.modal -->
            </div>

            <form name="ApplySerial" th:action="@{/ApplySerial}"
                  th:object="${applySerial_entity}"
                  id="ApplySerial" method="post">
                <div id="collapseOne" class="panel-collapse collapsein">
                    <div class="panel-body">
                        <div class="row">
                            <div class="col-lg-6">
                                <div class="col-lg-12">
                                    <label id="resultText"></label>
                                </div>
                            </div>
                        </div>
                        <br/>
                        <div id="failArea">

                            <div class="row">
                                <div class="col-lg-6">
                                    <div class="col-lg-4">
                                        <label>流程号:</label>
                                    </div>
                                    <div class="col-lg-8">
                                        <input class="form-control" readonly name="" maxlength="12"
                                               id="processId">
                                    </div>
                                </div>
                            </div>
                            <br/>
                            <div class="row">
                                <div class="col-lg-6">
                                    <div class="col-lg-4">
                                        <label>流程发起人:</label>
                                    </div>
                                    <div class="col-lg-8">
                                        <input class="form-control"
                                               readonly name="OOUser" maxlength="10" id="OOUser">
                                    </div>
                                </div>
                            </div>
                            <br/>
                            <div class="row">
                                <div class="col-lg-6">
                                    <div class="col-lg-4">
                                        <label>流程发起行号:</label>
                                    </div>
                                    <div class="col-lg-8">
                                        <input class="form-control"
                                               readonly name="" maxlength="10" id="startBankCode">
                                    </div>
                                </div>
                            </div>
                            <br/>
                            <div class="row">
                                <div class="col-lg-6">
                                    <div class="col-lg-4">
                                        <label>流程发起日期:</label>
                                    </div>
                                    <div class="col-lg-8">
                                        <input class="form-control"
                                               readonly name="startDate" maxlength="8" id="startDate">
                                    </div>
                                </div>
                            </div>
                            <br/>
                            <div class="row">
                                <div class="col-lg-6">
                                    <div class="col-lg-4">
                                        <label>目前行号:</label>
                                    </div>
                                    <div class="col-lg-8">
                                        <input class="form-control"
                                               readonly name="" maxlength="12" id="BankCode">
                                    </div>
                                </div>
                            </div>
                            <br/>
                        </div>
                        <div id="publicArea">
                            <div class="row">
                                <div class="col-lg-6">
                                    <div class="col-lg-4">
                                        <label>客户号:</label>
                                    </div>
                                    <div class="col-lg-8">
                                        <input class="form-control" readonly name="custCode" maxlength="12"
                                               id="custCode">
                                    </div>
                                </div>
                            </div>
                            <br/>
                            <div class="row">
                                <div class="col-lg-6">
                                    <div class="col-lg-4">
                                        <label>贷款申请号:</label>
                                    </div>
                                    <div class="col-lg-8">
                                        <input class="form-control"
                                               readonly name="BMP_NO" maxlength="12" id="BMP_NO">
                                    </div>
                                </div>
                            </div>
                            <br/>
                        </div>
                    </div>
                </div>
            </form>
        </div>


    </div>
</div>


<script>
    $(document).ready(function () {
        $('#failArea').hide();
        $('#publicArea').hide();
        $('#myModal').modal('show');
    })

    $('#confirm').click(function () {
        $('#myModal').modal('hide');
        $.ajax({
            type: 'get',
            url: '/ApplySerial/getAll',
            dataType: "json",
            ansyc: true,
            success: function (data) {
                if ((data.BPM_NO == "" || data.BPM_NO == undefined) && (data.custcode != "" || data.custcode != undefined))
                {
                    $('#BMP_NO').val(data.BPM_NO);
                    $('#custCode').val(data.custCode);
                    $('#resultText').html("提交申请成功!");
                    $('#failArea').hide();
                    $('#publicArea').show();
                }
               else
                {
                    $('#processId').val(data.processId);
                    $('#startBankCode').val(data.bankCode);
                    $('#BankCode').val(data.bankCode);
                    $('#OOUser').val(data.OOUser);
                    $('#BMP_NO').val(data.BPM_NO);
                    $('#custCode').val(data.custCode);
                    $('#startDate').val(data.startDate);
                    $('#resultText').html("已经存在未完成审批的流程!");
                    $('#failArea').show();
                    $('#publicArea').show();
                }
            },
            error: function () {
                alert("获取数据失败!");
            }
        });

//        //check insert
//        var bpm_no = $('#BPM_NO').val();
//        $.ajax({
//            type: "POST",
//            url: "/monitoring_insertCheck",
//            contentType: "application/json",
//            dataType: "html",
//            data: JSON.stringify({
//                bpm_no: bpm_no
//            }),
//            success: function (result) {
//                return result;
//            }
//        });

    })


</script>
</body>

</html>
